#!/usr/bin/env bash 
cd $(dirname $0)
main() {
    echo 
    comp 
}

#-------------------------
# 编译并运行
#-------------------------
function comp() {
    local src=$(find -type f -regex ".*\.\(c\|cpp\)")
    local lstr=""
    for i in $src 
    do 
        g++ -std=c++11 -c $i 
        if [[ $i == *".cpp" ]] ; then
            lstr="$lstr $(basename $i .cpp).o"
        elif [[ $i == *".c" ]] ; then
            lstr="$lstr $(basename $i .c).o"
        fi 
    done 
    echo $lstr 
    g++ -std=c++11 $lstr -o mexe
    mv mexe debug/mexe 
    chmod +x debug/mexe 
    ./debug/mexe
    rm -f *.o 
}


main $*  